// 属性整体计算
export function calcCount(data , isSSWQ , occAttr) {
    console.log("属性整体计算")
    console.log(data)
    let calcAttrPre = {
        wuqiZ:{
            hurt: 0,
            hurtlv: 0,
            wlzm: 0,
        },
        wuqiY:{
            hurt: 0,
            hurtlv: 0,
            wlzm: 0,
        },
        wuqiZHurtCount: 0,
        wuqiYHurtCount: 0,
        hp: 0,
        mfzfl: 0,
    }
    if(data.wuqiZPre&&!(JSON.stringify(data.wuqiZPre)=='{}')){
        calcAttrPre.wuqiZ.hurt = data.wuqiZPre.hurt
        calcAttrPre.wuqiZ.hurtlv = data.wuqiZPre.hurtlv
        calcAttrPre.wuqiZ.wlzm = data.wuqiZPre.wlzm

        calcAttrPre.hp += data.wuqiZPre.hp?data.wuqiZPre.hp:0
        calcAttrPre.mfzfl += data.wuqiZPre.mfzfl?data.wuqiZPre.mfzfl:0
        
        
        let model = data.wuqiZPre.strongMsModel?data.wuqiZPre.strongMsModel:{}
        if(model&&!(JSON.stringify(model)=='{}')){
            // 强化
            if(model.strongModel&&!(JSON.stringify(model.strongModel)=='{}')){
                calcAttrPre.wuqiZ.hurt += model.strongModel.wlgj?model.strongModel.wlgj:0
            }
            // 魔石
            if(model.msModel&&!(JSON.stringify(model.msModel)=='{}')){
                calcAttrPre.wuqiZ.hurtlv += model.msModel.ewlgj?model.msModel.ewlgj:0
            }
            
        }
    }
    if(data.wuqiYPre&&!(JSON.stringify(data.wuqiYPre)=='{}')){
        calcAttrPre.wuqiY.hurt = data.wuqiYPre.hurt
        calcAttrPre.wuqiY.hurtlv = data.wuqiYPre.hurtlv
        calcAttrPre.wuqiY.wlzm = data.wuqiYPre.wlzm

        calcAttrPre.hp += data.wuqiYPre.hp?data.wuqiYPre.hp:0
        calcAttrPre.mfzfl += data.wuqiYPre.mfzfl?data.wuqiYPre.mfzfl:0
        
        let model = data.wuqiYPre.strongMsModel?data.wuqiYPre.strongMsModel:{}
        if(model&&!(JSON.stringify(model)=='{}')){
            // 强化
            if(model.strongModel&&!(JSON.stringify(model.strongModel)=='{}')){
                calcAttrPre.wuqiY.hurt += model.strongModel.wlgj?model.strongModel.wlgj:0
            }
            // 魔石
            if(model.msModel&&!(JSON.stringify(model.msModel)=='{}')){
                calcAttrPre.wuqiY.hurtlv += model.msModel.ewlgj?model.msModel.ewlgj:0
            }
        }
    }
    // 合成武器直接加到左手武器里面
    if(data.wuqiZPre&&!(JSON.stringify(data.wuqiZPre)=='{}')&&data.wuqiHCPre&&!(JSON.stringify(data.wuqiHCPre)=='{}')){
        // console.log("合成武器")
        calcAttrPre.wuqiZ.hurt += data.wuqiHCPre.hurt
        calcAttrPre.wuqiZ.hurtlv += data.wuqiHCPre.hurtlv
        calcAttrPre.wuqiZ.wlzm += data.wuqiHCPre.wlzm

        calcAttrPre.hp += data.wuqiHCPre.hp?data.wuqiHCPre.hp:0
        calcAttrPre.mfzfl += data.wuqiHCPre.mfzfl?data.wuqiHCPre.mfzfl:0

        let model = data.wuqiHCPre.strongMsModel?data.wuqiHCPre.strongMsModel:{}
        // 只计算魔石，不计算强化
        if(model&&!(JSON.stringify(model)=='{}')){
            if(model.msModel&&!(JSON.stringify(model.msModel)=='{}')){
                calcAttrPre.wuqiZ.hurtlv += model.msModel.ewlgj?model.msModel.ewlgj:0
            }
        }
    }

    // 判断是否 双持武器
    let isDBWQ = !isSSWQ && data.wuqiZPre&&!(JSON.stringify(data.wuqiZPre)=='{}')&&data.wuqiYPre&&!(JSON.stringify(data.wuqiYPre)=='{}')
    
    if (isDBWQ) {
        // 左右手默认增加 36 绿色攻击力
        calcAttrPre.wuqiZ.hurtlv += 36
        calcAttrPre.wuqiY.hurtlv += 36
    }

    // 武器魔石计算
    if(data){
        for(var key3 in data){
            let hp = 0
            let ewlgj = 0
            let mfzfl = 0
            let wlzm = 0
            let strongMsModel = data[key3].strongMsModel
            if(strongMsModel&&!(JSON.stringify(strongMsModel)=='{}')){
                for(var val2 in strongMsModel){
                    hp += strongMsModel[val2].hp?strongMsModel[val2].hp:0
                    ewlgj += strongMsModel[val2].ewlgj?strongMsModel[val2].ewlgj:0
                    mfzfl += strongMsModel[val2].mfzfl?strongMsModel[val2].mfzfl:0
                    wlzm += strongMsModel[val2].ewlzm?strongMsModel[val2].ewlzm:0
                } 
            }
            calcAttrPre.hp += hp
            calcAttrPre.mfzfl += mfzfl
            // console.log(hp,ewlgj,mfzfl)
            if(isDBWQ){
                calcAttrPre.wuqiZ.hurtlv += ewlgj
                calcAttrPre.wuqiZ.wlzm += wlzm

                calcAttrPre.wuqiY.hurtlv += ewlgj
                calcAttrPre.wuqiY.wlzm += wlzm

            }else{
                calcAttrPre.wuqiZ.hurtlv += ewlgj
                calcAttrPre.wuqiZ.wlzm += wlzm
            }
        }
    }
    

    // 防具 属性计算 (计算魔石和强化)
    if(data.fjPre&&!(JSON.stringify(data.fjPre)=='{}')){
        let hp = 0
        let ewlgj = 0
        let mfzfl = 0
        let wlzm = 0
        for(var key in data.fjPre){
            hp += data.fjPre[key].hp?data.fjPre[key].hp:0
            ewlgj += data.fjPre[key].ewlgj?data.fjPre[key].ewlgj:0
            mfzfl += data.fjPre[key].mfzfl?data.fjPre[key].mfzfl:0

            let strongMsModel = data.fjPre[key].strongMsModel

            if(strongMsModel&&!(JSON.stringify(strongMsModel)=='{}')){
                for(var val in strongMsModel){
                    hp += strongMsModel[val].hp?strongMsModel[val].hp:0
                    ewlgj += strongMsModel[val].ewlgj?strongMsModel[val].ewlgj:0
                    mfzfl += strongMsModel[val].mfzfl?strongMsModel[val].mfzfl:0
                    wlzm += strongMsModel[val].wlzm?strongMsModel[val].wlzm:0
                }
            }
        }
        calcAttrPre.hp += hp
        calcAttrPre.mfzfl += mfzfl
        // console.log(hp,ewlgj,mfzfl)
        if(isDBWQ){
            calcAttrPre.wuqiZ.hurtlv += ewlgj
            calcAttrPre.wuqiZ.wlzm += wlzm

            calcAttrPre.wuqiY.hurtlv += ewlgj
            calcAttrPre.wuqiY.wlzm += wlzm

        }else{
            calcAttrPre.wuqiZ.hurtlv += ewlgj
            calcAttrPre.wuqiZ.wlzm += wlzm
        }
        
    }

    // 饰品 属性计算 （只计算基本属性）
    if(data.spPre&&!(JSON.stringify(data.spPre)=='{}')){
        let hp = 0
        let ewlgj = 0
        let mfzfl = 0
        let wlzm = 0
        for(var key2 in data.spPre){
            hp += data.spPre[key2].hp?data.spPre[key2].hp:0
            ewlgj += data.spPre[key2].ewlgj?data.spPre[key2].ewlgj:0
            mfzfl += data.spPre[key2].mfzfl?data.spPre[key2].mfzfl:0
            wlzm += data.spPre[key2].wlzm?data.spPre[key2].wlzm:0
        }
        calcAttrPre.hp += hp
        calcAttrPre.mfzfl += mfzfl
        // console.log(hp,ewlgj,mfzfl)
        if(isDBWQ){
            calcAttrPre.wuqiZ.hurtlv += ewlgj
            calcAttrPre.wuqiZ.wlzm += wlzm

            calcAttrPre.wuqiY.hurtlv += ewlgj
            calcAttrPre.wuqiY.wlzm += wlzm

        }else{
            calcAttrPre.wuqiZ.hurtlv += ewlgj
            calcAttrPre.wuqiZ.wlzm += wlzm
        }
        
    }

    // 50级人物基础属性
    calcAttrPre.hp += Number(occAttr.hp)

    // 套装属性
    if(data.tzInfo){
        let hp = 0
        let ewlgj = 0
        let mfzfl = 0
        let wlzm = 0

        for(var keys in data.tzInfo){
            hp += data.tzInfo[keys].ehp?Number(data.tzInfo[keys].ehp.split('+')[1]):0
            ewlgj += data.tzInfo[keys].ewlgj?Number(data.tzInfo[keys].ewlgj.split('+')[1]):0
            mfzfl += data.tzInfo[keys].emfzfl?Number(data.tzInfo[keys].emfzfl.split('+')[1]):0
            wlzm += data.tzInfo[keys].ewlzm?Number(data.tzInfo[keys].ewlzm.split('+')[1]):0
        }
        // console.log(hp,ewlgj,mfzfl,wlzm)
        if(isDBWQ){
            calcAttrPre.wuqiZ.hurtlv += ewlgj
            calcAttrPre.wuqiZ.wlzm += wlzm

            calcAttrPre.wuqiY.hurtlv += ewlgj
            calcAttrPre.wuqiY.wlzm += wlzm

        }else{
            calcAttrPre.wuqiZ.hurtlv += ewlgj
            calcAttrPre.wuqiZ.wlzm += wlzm
        }
        calcAttrPre.hp += hp
        calcAttrPre.mfzfl += mfzfl
    }

    // 攻击力汇总
    calcAttrPre.wuqiZHurtCount = calcAttrPre.wuqiZ.hurt + calcAttrPre.wuqiZ.hurtlv
    calcAttrPre.wuqiYHurtCount = calcAttrPre.wuqiY.hurt + calcAttrPre.wuqiY.hurtlv

    
    console.log("calcAttrPre")
    console.log(calcAttrPre)

    return calcAttrPre
    // 右手白字攻击力
}